<?php
declare(strict_types=1);
namespace App\ZxAdmin\Sys;
use App\Controller;
use Field\SysMenuRow;

// hook controller_zxadmin_sys_config_sys_menu_use.php

/**
 * @title   菜单管理
 * @auth    true
 * @login   true
 * @menu    true
 * @component vlist/index.vue
 * @icon el-icon-menu
 * @rank    3
 */
class SysMenu extends Controller
{
    // hook controller_zxadmin_sys_config_sys_menu_public_start.php

    // hook controller_zxadmin_sys_config_sys_menu_public_end.php


    /**
     * @title   获取页面配置
     * @rank    99
     */
    public function action_Conf_PUT()
    {
        // hook controller_zxadmin_sys_config_sys_menu_conf_start.php
        $Columns=[
          ['prop'=>'Node','label'=>'节点'],
          ['prop'=>'ParentNode','label'=>'父节点'],
          ['prop'=>'Name','label'=>'名称'],
          ['prop'=>'Method','label'=>'请求方式','width'=>'64'],
          ['prop'=>'Icon','type'=>'icon','label'=>'图标','width'=>'32','editable'=>false],
          ['prop'=>'Rank','label'=>'排序','width'=>'64'],
          ['prop'=>'Component','label'=>'页面模板'],
          ['prop'=>'TypeId','label'=>'类型','width'=>'64'],
        ];
        $Conf = [
            'Index'=>'Node',
            'TreeData'=>true,
            'rowField'=>'Node',
            'pageSize' => 25,
            'pageSizes' => [10,20,25,50,100,500,1000,10000],
            'remoteSort'=>0,
            'remoteFilter'=>0,
            'remoteSummary'=>0,
            'hidePagination'=>1,
            'hideRefresh'=>0,
            'add'=>0,
            'start'=>0,
            'stop'=>0,
            'delete'=>0,
            'import'=>0,
            'export'=>0
        ];
        // hook controller_zxadmin_sys_config_sys_menu_conf_end.php
        $this->response('0000', ['Conf' => $Conf, 'Filter' => [], 'Tools' => [], 'Columns' => $Columns, 'data' => []]);

    }

    /**
     * @title   获取页面数据
     * @rank    99
     */
    public function action_Index()
    {
        // hook controller_zxadmin_sys_config_sys_menu_index_start.php
        $data = $this->SysMenu->select();
        foreach ($data as &$row){
          $row['_index']=$row['Node'].($row['Method']?'_'.$row['Method']:'');
        }
        //$data = arraylist_tree($data, 'Node', 'ParentNode');
        // hook controller_zxadmin_sys_config_sys_menu_index_end.php
        $this->response('0000', ['data' =>$data]);
    }


    // hook controller_zxadmin_sys_config_sys_menu_end.php
}
?>